<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd
                           http://www.springframework.org/schema/tx
                           http://www.springframework.org/schema/tx/spring-tx.xsd">

  <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    <property name="driverClass" value="org.h2.Driver" />
    <property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1" />
    <property name="username" value="sa" />
    <property name="password" value="" />
  </bean>

  <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
  </bean>

  <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="persistenceXmlLocation">
      <value>classpath:/org/camunda/bpm/engine/spring/test/jpa/custom-persistence.xml</value>
    </property>
    <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="H2" />
      </bean>
    </property>
  </bean>
  
  <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
    <property name="authorizationEnabled" value="true"/>
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="false" />
    <!-- turn off metrics reporter -->
    <property name="dbMetricsReporterActivate" value="false" />
    <property name="telemetryReporterActivate" value="false" />
    <property name="taskMetricsEnabled" value="false" />

    <property name="processEnginePlugins">
      <list>
        <bean id="crdbInterceptorPluginBean"
              class="org.camunda.bpm.engine.spring.test.transaction.crdb.CrdbRetryInterceptorPlugin" />
      </list>
    </property>
  </bean>

  <bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

  <bean id="processEngineRule" class="org.camunda.bpm.engine.test.ProcessEngineRule">
    <property name="processEngine" ref="processEngine"/>
  </bean>

  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />

  <context:annotation-config />
  <context:component-scan base-package="org.camunda.bpm.engine.spring.test.transaction.crdb" />
  <tx:annotation-driven />

</beans>